package com.drakulo.hi.gfx;

import java.util.Map;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;

import com.drakulo.hi.logic.actors.Hero;
import com.drakulo.hi.logic.inventory.equipment.Equipment;
import com.drakulo.hi.logic.inventory.equipment.EquipmentType;

public class EquipmentGfx {
	public static final int HELMET_X = 65;
	public static final int HELMET_Y = 270;

	public static final int ARMOR_X = 65;
	public static final int ARMOR_Y = 310;

	public static final int RIGHT_HAND_X = 25;
	public static final int RIGHT_HAND_Y = 326;

	public static final int LEFT_HAND_X = 104;
	public static final int LEFT_HAND_Y = 326;

	public static final int BOOTS_X = 65;
	public static final int BOOTS_Y = 366;

	public static void render(Graphics g, Hero h) {
		// 1. On génère le rendu du fond :
		// renderBackground(g, Team.getHeroDisplayX(h));

		// 2. On génère le rendu de l'équipement :
		// renderEquipment(g, h, Team.getHeroDisplayX(h));
	}

	private static void renderBackground(Graphics g, int delta) {
		g.setColor(Color.white);

		// Casque
		g.drawRect(HELMET_X + delta, HELMET_Y, Item.SPRITE_SIZE, Item.SPRITE_SIZE);

		// Armure
		g.drawRect(ARMOR_X + delta, ARMOR_Y, Item.SPRITE_SIZE, Item.SPRITE_SIZE);

		// Main droite (affichée à gauche!)
		g.drawRect(RIGHT_HAND_X + delta, RIGHT_HAND_Y, Item.SPRITE_SIZE, Item.SPRITE_SIZE);

		// Main gauche (affichée à droite!)
		g.drawRect(LEFT_HAND_X + delta, LEFT_HAND_Y, Item.SPRITE_SIZE, Item.SPRITE_SIZE);

		// Bottes
		g.drawRect(BOOTS_X + delta, BOOTS_Y, Item.SPRITE_SIZE, Item.SPRITE_SIZE);
	}

	private static void renderEquipment(Graphics g, Hero h, int delta) {
		Map<EquipmentType, Equipment> equipments = h.getEquipments();

		// Casque
		Equipment helmet = equipments.get(EquipmentType.HELMET);
		if (helmet != null) {
			g.drawImage(helmet.getSprite(), HELMET_X + delta, HELMET_Y);
		}

		// Armure

		// Main droite (affichée à gauche!)
		Equipment rightHand = equipments.get(EquipmentType.WEAPON);
		if (rightHand != null) {
			g.drawImage(rightHand.getSprite(), RIGHT_HAND_X + delta, RIGHT_HAND_Y);
		}

		// Main gauche (affichée à droite!)

		// Bottes
	}
}
